package com.qigao.mall.service.impl;

import com.qigao.mall.api.IntentCustomerService;
import com.qigao.mall.commons.dto.IntentCustomerApplyDto;
import com.qigao.mall.jdbc.mapper.TbIntentCustomerMapper;
import com.qigao.mall.jdbc.model.TbIntentCustomer;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author luiz
 * @Title: com.qigao.mall.service.impl
 * @ProjectName three-mall
 * @date 2020-04-2020/4/22 17:56
 * @Description:
 */
@Service
public class IntentCustomerServiceImpl implements IntentCustomerService {
    @Resource
    private TbIntentCustomerMapper intentCustomerMapper;
    @Override
    public void create(IntentCustomerApplyDto intentCustomerApplyDto) {
        TbIntentCustomer tbIntentCustomer=intentCustomerMapper.selectByPhoneNum(intentCustomerApplyDto.getCustomerPhone());
        if(tbIntentCustomer!=null) return;
         tbIntentCustomer=new TbIntentCustomer();
        BeanUtils.copyProperties(intentCustomerApplyDto,tbIntentCustomer);
        tbIntentCustomer.setCreateTime(new Date());
        tbIntentCustomer.setModiTime(new Date());
        intentCustomerMapper.insertSelective(tbIntentCustomer);
    }
}
